import myModule, { MyModule, CreateDataResponseType, DataItemTypeStr } from './myModules.d'
import axios, { AxiosInstance, Axios } from 'axios'

new Axios()

// 泛型 主要用于引用类型
function createData(): Promise<CreateDataResponseType<DataItemTypeStr>> {
  return new Promise((resolve, reject) => {
    resolve({
      code: 0,
      msg: 'sussess',
      // data: [{ id: 1 }, { id: '2' }],
      // data: { username: 'devin', password: '123', token: 123 },
      data: 'token',
    })
  })
}

let p = new MyModule()
p.get()

const fetchData = async () => {
  const res = await createData()
}
fetchData()

/**
 * 模块内部是一个封闭的作用域
 * 1. 模块要抛出一个统一的模块注解，
 * 2. 模块还能抛出单个注解
 *
 */
